using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class GameManager : MonoBehaviour
{
    public static GameManager Instance { get; private set; }
    public Sprite[] cards;
    public CardsPanel cardsPanel;
    public TMP_Text scoreText;
    public int score = 0;
    
    void Awake() 
    {
        if (Instance == null )
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }
    
    void Start()
    {
        StartGame();
    }

    public void StartGame()
    {
        cardsPanel.Init();
        UpdateScore(0);
    }

    public void UpdateScore(int newScore)
    {
        score = newScore;
        scoreText.text = score.ToString();
    }

    public void GameOver()
    {
        Debug.Log("GameOver");
    }

    public void MatchFlipCard(Card card)
    {
        cardsPanel.MatchCard(card);
    }
}
